package com.tlvip;

import java.util.Arrays;

/**
 * <p>description：</p>
 * <p>copyright： copyright(C)2016-2099</p>
 * <p>Life is short,we need passion</p>
 * <p>Summary： </p>
 * <p>instructions： </p>
 * Date 2/26/21</p>
 * Author mac
 *
 * @version 1.0
 */
public class PatternTest {

    // 代表任何一个字符
    private static final String REGEX_ANY_CHAR = ".";

    // \d 代表0-9中的任何一个数字
    private static final String REGEX_ANY_DIGIT = "\\d";

    // \D 代表0-9中的任何一个数字
    private static final String REGEX_ANY_NOT_DIGIT = "\\D";

    // \s代表空格类字符,'\t'、'\n'、'\x0B'、'\f'、'\r'
    private static final String REGEX_ANY_BLANK = "\\s";

    // \S代表非空格类字符
    private static final String REGEX_ANY_NOT_BLANK = "\\s";


    private static final String REGEX_RANGE = "[a-c[e-f]]";

//    private static final String REGEX_DIGIT_MORE_THAN_0 = "[1-9]{1,}[0-9]*";
//    private static final String REGEX_DIGIT_MORE_THAN_0 = "^[0-9]*[1-9][0-9]*";
//    private static final String REGEX_DIGIT_MORE_THAN_0 = "^[1-9][0-9]*";
//    private static final String REGEX_DIGIT_MORE_THAN_0 = "^[1-9]\\d*";
//    private static final String REGEX_DIGIT_MORE_THAN_0 = "^[1-9]\\p{Digit}*";

    private static final String REGEX_DIGIT_LESS_THAN_0 = "^-\\d*|0";


    public static void main(String[] args) {
//        for (int i = -1000; i < 2; i++) {
//            if (!String.valueOf(i).matches(REGEX_DIGIT_LESS_THAN_0)) {
//                System.out.println(i + " <=0 :" + String.valueOf(i).matches(REGEX_DIGIT_LESS_THAN_0));
//            }
//        }

//        for (char ch : "1!2@3#".toCharArray()) {
//            System.out.println(String.valueOf(ch).matches(REGEX_ANY_CHAR));
//        }

//        for (char ch : "0123456789".toCharArray()) {
//            System.out.println(String.valueOf(ch).matches(REGEX_ANY_DIGIT));
//        }

//        for (char ch : "12QwEq".toCharArray()) {
//            System.out.println(String.valueOf(ch).matches(REGEX_ANY_NOT_DIGIT));
//        }

//        System.out.println("".matches(REGEX_ANY_BLANK));
//        System.out.println(" ".matches(REGEX_ANY_BLANK));

//        System.out.println("8i9".matches(REGEX_ANY_NOT_BLANK));
//        System.out.println(" ".matches(REGEX_ANY_NOT_BLANK));

//        System.out.println("ab".matches(REGEX_RANGE));
//        System.out.println("b".matches(REGEX_RANGE));
//        System.out.println("e".matches(REGEX_RANGE));
//        System.out.println("ad".matches(REGEX_RANGE));
//        System.out.println("ef".matches(REGEX_RANGE));
//        System.out.println("fg".matches(REGEX_RANGE));

//        checkEmail();

//        System.out.println(toUpOrLow("tr1U3iO"));
//        String str = "2343";
//        str.toUpperCase();

//        testPrint();
//        testSort();
        testCopy();
    }


    private static void checkEmail() {
        String regex = "\\w{1,}@\\w{1,}\\.\\w{1,}";
        System.out.println("zhangsan@sina.com".matches(regex));
        System.out.println("li@si@dl.cn".matches(regex));
        System.out.println("\56");
    }

    private static String toUpOrLow(String str) {
        if (str == null || str.equals("")) {
            return str;
        }
        StringBuffer sb = new StringBuffer();
        char[] values = str.toCharArray();
        for (char ch : values) {
            if (ch <= 'z' && ch >= 'a') {
                int temp = ch - 32;
                sb.append((char) temp);
            } else if (ch >= 'A' && ch <= 'Z') {
                int temp = ch + 32;
                sb.append((char) temp);
            } else {
                sb.append(ch);
            }
        }
        return sb.toString();
    }

    private static void testPrint() {
        String s = "中国科学技术大学";
        char a = s.charAt(2);
        char b = s.charAt(6);
        System.out.println(a);
        System.out.println(b);
    }

    private static void testSort() {
        int a[] = {23, 67, 89, 90, -987};
        double b[] = {12.89, 90.87, 34, 678.987, -98.78, 0.89};
        Arrays.sort(a);
        Arrays.sort(b, 1, 4);
        for (int intNum : a) {
            System.out.print(intNum + "  ");
        }
        System.out.println("");
        for (double dd : b) {
            System.out.print(dd + "  ");
        }
        System.out.println("");

    }

    private static void testCopy() {
        char a1[] = {'a', 'b', 'c', 'd', 'e', 'f'};
        char b1[] = {'1', '2', '3', '4', '5', '6'};
        System.arraycopy(a1, 0, b1, 1, a1.length - 1);
        System.out.println(new String(a1));
        System.out.println(new String(b1));
    }

}
